主题
获取软件更新状态 - GetSoftUpdateStatus
函数简介
获取客户端软件更新状态,并返回最新版本业务信息。
返回数据格式:
json
{
"Code": 1,
"Message": "",
"CurrentVersion": "1.0.0",
"LatestVersion": "1.1.0",
"HasUpdate": true,
"SoftVersion": {
"SoftCode": "demo-soft",
"VersionNumber": "1.1.0",
"VersionName": "2026春季版",
"VersionType": 1,
"FileName": "demo-installer.exe",
"FileSize": 12345678,
"FileMd5": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"FileUrl": "https://example.com/demo-installer.exe",
"IsForceUpdate": false,
"UpdateContent": "修复已知问题并优化稳定性",
"ReleaseDate": "2026-04-24 09:00:00",
"IsLatest": true
}
}| 字段名 | 类型 | 说明 |
|---|---|---|
| Code | 整数 | 结果状态码,通常 1 表示成功,0 或其他值表示失败。 |
| Message | 字符串 | 提示信息或错误信息,成功时通常为空字符串。 |
| CurrentVersion | 字符串 | 当前版本号。 |
| LatestVersion | 字符串 | 最新版本号。 |
| HasUpdate | 布尔 | 是否存在可更新版本。 |
| SoftVersion | 对象 | 版本对象信息。 |
SoftVersion 字段说明:
| 字段名 | 类型 | 说明 |
|---|---|---|
| SoftCode | 字符串 | 软件编码。 |
| VersionNumber | 字符串 | 版本号。 |
| VersionName | 字符串 | 版本名称。 |
| VersionType | 整数 | 版本类型编码。 |
| FileName | 字符串 | 安装包文件名。 |
| FileSize | 整数 | 安装包大小(字节)。 |
| FileMd5 | 字符串 | 安装包 MD5 校验值。 |
| FileUrl | 字符串 | 安装包下载地址。 |
| IsForceUpdate | 布尔 | 是否强制更新。 |
| UpdateContent | 字符串 | 更新说明内容。 |
| ReleaseDate | 字符串 | 版本发布时间。 |
| IsLatest | 布尔 | 是否为最新版本。 |
接口名称
GetSoftUpdateStatusDLL调用
long GetSoftUpdateStatus(string userCode, string softCode, string softVersion, string dealerCode);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| userCode | 字符串 | 用户码。 |
| softCode | 字符串 | 软件码。 |
| softVersion | 字符串 | 软件版本。 |
| dealerCode | 字符串 | 经销商码。 |
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
int ret = ola.GetSoftUpdateStatus("value", "value", "value", "value");csharp
using OLAPlug;
var ola = new OLAPlugServer();
int ret = ola.GetSoftUpdateStatus("value", "value", "value", "value");python
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
ret = ola.GetSoftUpdateStatus("value", "value", "value", "value")java
import com.olaplug.OLAPlugServer;
OLAPlugServer ola = new OLAPlugServer();
int ret = ola.GetSoftUpdateStatus("value", "value", "value", "value");cpp
var ola = com("OlaPlug.OlaSoft")
var ret = ola.GetSoftUpdateStatus("value", "value", "value", "value")vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
ret = ola.GetSoftUpdateStatus("value", "value", "value", "value")text
.局部变量 ola, OLAPlug
ola.创建 ()
ret = ola.GetSoftUpdateStatus(“value”, “value”, “value”, “value”)aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var ret = ola.GetSoftUpdateStatus("value", "value", "value", "value");text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
整数 ret = ola.GetSoftUpdateStatus("value", "value", "value", "value")cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
int32_t ret = ola.GetSoftUpdateStatus("value", "value", "value", "value");原生 DLL 调用
cpp
long ptr = GetSoftUpdateStatus(instance, "value", "value", "value", "value");
if (ptr != 0) {
char buffer[512] = {0};
GetStringFromPtr(ptr, buffer, sizeof(buffer));
FreeStringPtr(ptr);
}csharp
using System.Runtime.InteropServices;
using System.Text;
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetStringFromPtr(long ptr, StringBuilder lpString, int size);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int FreeStringPtr(long ptr);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetStringSize(long ptr);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long GetSoftUpdateStatus(string userCode, string softCode, string softVersion, string dealerCode);
long ptr = GetSoftUpdateStatus(instance, "value", "value", "value", "value");
if (ptr != 0) {
StringBuilder sb = new StringBuilder(GetStringSize(ptr) + 1);
GetStringFromPtr(ptr, sb, sb.Capacity);
FreeStringPtr(ptr);
string result = sb.ToString();
}python
from ctypes import CDLL, c_int, c_int64, create_string_buffer
ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
ptr = ola.GetSoftUpdateStatus(instance, "value", "value", "value", "value")
if ptr:
buf = create_string_buffer(512)
ola.GetStringFromPtr(ptr, buf, 512)
ola.FreeStringPtr(ptr)
result = buf.value.decode("utf-8")返回值
成功返回 JSON 字符串格式的更新状态结果;失败返回 0。
注意事项
- 返回的字符串指针需要调用 FreeStringPtr 接口释放内存。
HasUpdate可直接用于判断是否提示更新。
